<?php

require_once(WSB_MODULES_PATH . 'sherpa/models/BasketGateway.php');

class Sherpa_BasketController extends WSB_Xtension_Extension
{

	/**
	 * @return string
	 */
	public function renderForBackend()
	{
		return get_class($this);
	}

	/**
	 * Index Action
	 */
	public function indexAction()
	{
		$gateway = new Sherpa_Model_BasketGateway();
		$productCount = $gateway->countProducts();
		$this->_view->productCount = $productCount;
		$this->_view->productId = intval($this->getParam('id', 0));
		$this->addContent($this->_view->render('basket/index.phtml'));
	}

	public function lastaddedAction()
	{
		$gateway = new Sherpa_Model_BasketGateway();
		$languageId = $this->getLanguageId();
		$products = $gateway->fetchProducts($languageId);
		$products->loadColorApplications();
		$products->loadMainImages($languageId);
		$products->loadImageVariants();
		$this->assignToView('products', $products);
		$this->assignToView('productCount', $gateway->countProducts());
		echo $this->_view->render('basket/last_added.phtml');
		exit;
	}

}
